using AutojsController.Helpers;
using AutojsController.ViewModels;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Notifications;
using Avalonia.Interactivity;
using SukiUI.Toasts;

namespace AutojsController.Views;

public partial class ScanMobilesDialogView : UserControl
{
    public ScanMobilesDialogView()
    {
        InitializeComponent();
    }

    private void ScanButton_Click(object? sender, RoutedEventArgs e)
    {
        var toastManager = (Application.Current as App)!.GetRequiredService<ISukiToastManager>();
        if (!StartIPTextBox.IsValidIPAddress())
        {
            SukiToast.Error(toastManager, "起始IP地址无效");
            StartIPTextBox.Focus(0);
            e.Handled = true;
            return;
        }
        if (!EndIPTextBox.IsValidIPAddress())
        {
            SukiToast.Error(toastManager, "结束IP地址无效");
            EndIPTextBox.Focus(0);
            e.Handled = true;
            return;
        }
    }
}